<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>

  <div id="app">
    <compa :propa="username" :propb='true' :propd="{name:'xiaoming',age:20}" :propc="[1,2,3]" :propf="handler"
      :proph="['apple','banana']" propi="gp18-1"></compa>
  </div>


  <script>
    const compa = {
      props: {
        propa: String,
        propb: {
          type: Boolean,
          required: true
        },
        propc: Array,
        propd: {
          type: Object,
          required: true
        },
        propf: {
          required: true,
          type: Function
        },
        proph: {
          required: true,
          validator: function (value) {
            if (value.indexOf('banana') > -1) {
              return true;
            } else {
              return false;
            }
          }

        },
        propi: {
          default() {
            return 'gp18'
          }
        }
      },
      template: `
      <div>
        <h1>
         {{propi}}
        </h1>
      </div>
      `,
    }


    var vm = new Vue({
      el: "#app",
      data: {
        username: "20",
        gp18: 'gp18-1'
      },
      components: {
        compa
      },
      methods: {
        handler() {

        }
      }
    })

  </script>

</body>

</html>